package wid;

import static org.junit.Assert.assertFalse;
import robocode.HitWallEvent;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.testing.RobotTestBed;

/**
 * Ensures that Pacifist doesn't run into walls.
 * 
 * @author David Wilkie
 */
public class TestPacifistHitsNoWalls extends RobotTestBed {

  // True if Pacifist hits a wall
  boolean hitWall = false;
  
  /**
   * Sets hitWall to true if Pacifist hits wall.
   * 
   * @param event HitWallEvent contains information about the wall collision
   */
  public void onHitWall(HitWallEvent event) {
    this.hitWall = true;
  }
  
  /**
   * Specifies that Fire and Pacifist are to be matched up in this test case.
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Fire,wid.Pacifist";
  }
  
  /**
   * This test runs for 10 rounds.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 5;
  }
  
  /**
   * After running all matches, fails test if Pacifist has hit a wall.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {  
    assertFalse("The robot has fired", this.hitWall);
  }  
}
